package easy.netty.net.ws;

import easy.netty.net.core.AbsClient;
import easy.netty.net.core.ws.WsClientIoHandler;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.http.HttpClientCodec;
import io.netty.handler.codec.http.HttpObjectAggregator;

/**
 * @author cengy
 */
public abstract class WsClient
        extends AbsClient {

    public WsClient() {
        super();
    }

    @Override
    protected ChannelHandler newHandler() {
        return new WsClientIoHandler(this);
    }

    @Override
    protected void initChannel0(Channel ch) throws Exception {
        ChannelPipeline p = ch.pipeline();

        p.addLast(new HttpClientCodec())
                .addLast(new HttpObjectAggregator(65535));
        super.initChannel0(ch);
    }
}
